<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

	<!-- This code written by : Willie Wheeler and John Wheeler -->
	<!-- For 'Spring In Practice' [Book written by Willie Wheeler and John Wheeler] -->

<c:url var="stylesUrl" value="/styles.css"/>

<html>
	<head>
		<title>${forum.name} Forum</title>
		<link rel="stylesheet" type="text/css" href="${stylesUrl}">
	</head>
	<body>
		<jsp:include page="header.jsp"/>
		<div id="body">
			<div><a href="home.do">Home</a> &gt; ${forum.name}</div>
			
			<h1>${forum.name} Forum</h1>
			
			<p>${fn:length(forum.messages)} messages | <a href="post.do?forumId=${forum.id}">Post message</a></p>
			
			<c:if test="${not empty forum.messages}">
				<table style="width:600px">
					<tr>
						<th>Message</th>
						<th>Author</th>
						<th>Date</th>
					</tr>
					<c:forEach var="message" items="${forum.messages}">
						<tr>
							<td>
								<a href="message.do?id=${message.id}">${message.subject}</a>
								<c:if test="${not message.visible}"><b>[BLOCKED]</b></c:if>
							</td>
							<td>${message.author}</td>
							<td><fmt:formatDate value="${message.date}"/></td>
						</tr>
					</c:forEach>
				</table>
			</c:if>
		</div>
	</body>
</html>
